﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VehicleMaintenance.Events
{
	public class KeyEvents
	{
		/// <summary>
		/// 限制只能输入数字
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public static void Number_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (!(char.IsNumber(e.KeyChar) || char.IsControl(e.KeyChar)))
			{
				e.Handled = true;
			}
		}

		/// <summary>
		/// 限制只能输入浮点数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public static void Decimal_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (!(char.IsNumber(e.KeyChar) || e.KeyChar.ToString().Equals(".") || char.IsControl(e.KeyChar)))
			{
				e.Handled = true;
			}
		}

		/// <summary>
		/// 禁止输入可见字符
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public static void DisabledInput_KeyPress(object sender, KeyPressEventArgs e)
		{
			e.Handled = true;
		}

		/// <summary>
		/// 禁止输入控制字符
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public static void DisabledInput_KeyDown(object sender, KeyEventArgs e)
		{
			e.Handled = true;
		}
	}
}
